import moment from "moment";

let unit = 60;
export let config = {
    unit: 60,
    focus_duration: 90 * unit, //集中时长
    cycle_num: 3, //循环次数
    long_break: {
        duration: 20 * unit,
        tone: "/tone/ding.mp3",
    }, //休息时长
    short_break: {
        duration: 10,
        trigger_range: {
            start: 3 * unit,
            end: 5 * unit,
        },
        tone: "/tone/di.wav",
    },
};

export function format(duration) {
    let minutes = Math.floor(duration / 60);
    let seconds = duration % 60;
    return (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
}

export function getRandomInt(min, max) {
    return Number.parseInt(Math.floor(Math.random() * (max - min + 1)) + min);
}

export function playTone(path) {
    let audio = new Audio(path);
    audio.play().then(r => {
        console.log("Tone played", path)
    });
}